Include a header file required for build on mac 10.4
[supercollider.git] / Help / Tutorials / Getting-Started / Scoping and Plotting.html
blobe8e9d92f01c750779c5f1d117b3703fa87264114
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta http-equiv="Content-Style-Type" content="text/css">
6 <title></title>
7 <meta name="Generator" content="Cocoa HTML Writer">
8 <meta name="CocoaVersion" content="824.42">
9 <style type="text/css">
10 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica}
11 p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica; min-height: 22.0px}
12 p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
14 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
15 p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
16 p.p7 {margin: 0.0px 0.0px 0.0px 0.0px}
17 p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica}
18 p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #a71e12}
19 p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica; min-height: 17.0px}
20 p.p11 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #0000ff}
21 span.s1 {color: #0019b7}
22 span.s2 {font: 12.0px Helvetica}
23 span.s3 {color: #000000}
24 span.s4 {color: #0000ff}
25 span.Apple-tab-span {white-space:pre}
26 </style>
27 </head>
28 <body>
29 <p class="p1"><b>Scoping Out Some Plots</b></p>
30 <p class="p2"><br></p>
31 <p class="p3">Function has two other useful audio related methods. The first you've already seen some results of, Function-plot:</p>
32 <p class="p4"><br></p>
33 <p class="p5"><span class="Apple-tab-span"> </span>{ <span class="s1">PinkNoise</span>.ar(0.2) + <span class="s1">SinOsc</span>.ar(440, 0, 0.2) + <span class="s1">Saw</span>.ar(660, 0.2) }.plot;</p>
34 <p class="p6"><span class="Apple-tab-span"> </span></p>
35 <p class="p3">This makes a graph of the signal produced by the output of the Function. You can specify some arguments, such as the duration. The default is 0.01 seconds, but you can set it to anything you want.</p>
36 <p class="p4"><br></p>
37 <p class="p5"><span class="Apple-tab-span"> </span>{ <span class="s1">PinkNoise</span>.ar(0.2) + <span class="s1">SinOsc</span>.ar(440, 0, 0.2) + <span class="s1">Saw</span>.ar(660, 0.2) }.plot(1);</p>
38 <p class="p6"><span class="Apple-tab-span"> </span></p>
39 <p class="p3">This can be useful to check what's happening, and if you're getting the output you think you're getting.</p>
40 <p class="p4"><br></p>
41 <p class="p3">The second method, Function-scope, shows an oscilloscope-like display of the Function's output. This only works with what is called the internal server, so you'll need to boot that before it will work. You can do this using the internal server window</p>
42 <p class="p4"><br></p>
43 <p class="p4"><br></p>
44 <p class="p7"><span class="s2"><img src="attachments/Scoping and Plotting/Pasted Graphic.png" alt="attachments/Scoping and Plotting/Pasted Graphic.png"></span></p>
45 <p class="p4"><br></p>
46 <p class="p4"><br></p>
47 <p class="p3">or you can do it in code, like so:</p>
48 <p class="p4"><br></p>
49 <p class="p5"><span class="Apple-tab-span"> </span>Server.internal.boot;</p>
50 <p class="p6"><span class="Apple-tab-span"> </span></p>
51 <p class="p3">BTW, clicking on the '-&gt; default' button on the localhost or internal server's window sets that server to be the default, and stores it in the variable 's'. Thereafter, that will be the server on which all audio is played, unless you specify another one. Since Function-scope only works with the internal server, however, it will always play on it.</p>
52 <p class="p4"><br></p>
53 <p class="p3">So let's try to scope some audio:</p>
54 <p class="p4"><br></p>
55 <p class="p5"><span class="Apple-tab-span"> </span>{ <span class="s1">PinkNoise</span>.ar(0.2) + <span class="s1">SinOsc</span>.ar(440, 0, 0.2) + <span class="s1">Saw</span>.ar(660, 0.2) }.scope;</p>
56 <p class="p6"><span class="Apple-tab-span"> </span></p>
57 <p class="p3">This should open a window which looks something like this:</p>
58 <p class="p4"><br></p>
59 <p class="p4"><br></p>
60 <p class="p7"><span class="s2"><img src="attachments/Scoping and Plotting/Pasted Graphic 1.png" alt="attachments/Scoping and Plotting/Pasted Graphic 1.png"></span></p>
61 <p class="p4"><br></p>
62 <p class="p4"><br></p>
63 <p class="p3">This also works for multiple channels:</p>
64 <p class="p4"><br></p>
65 <p class="p5"><span class="Apple-tab-span"> </span>{ [<span class="s1">SinOsc</span>.ar(440, 0, 0.2), <span class="s1">SinOsc</span>.ar(442, 0, 0.2)] }.scope;</p>
66 <p class="p6"><span class="Apple-tab-span"> </span></p>
67 <p class="p3">Scope also has a zoom argument. Higher values 'zoom out'.</p>
68 <p class="p4"><br></p>
69 <p class="p5"><span class="Apple-tab-span"> </span>{ [<span class="s1">SinOsc</span>.ar(440, 0, 0.2), <span class="s1">SinOsc</span>.ar(442, 0, 0.2)] }.scope(zoom: 10);</p>
70 <p class="p4"><br></p>
71 <p class="p3">Like Function-plot, Function-scope can be useful for testing purposes, and to see if you're actually getting out what you think you are.</p>
72 <p class="p4"><br></p>
73 <p class="p8"><b>Scoping on Demand</b></p>
74 <p class="p4"><br></p>
75 <p class="p3">You can also scope the output of the internal server at any time, by calling 'scope' on it.</p>
76 <p class="p4"><br></p>
77 <p class="p5"><span class="Apple-tab-span"> </span>{ [<span class="s1">SinOsc</span>.ar(440, 0, 0.2), <span class="s1">SinOsc</span>.ar(442, 0, 0.2)] }.play(<span class="s1">Server</span>.internal);</p>
78 <p class="p9"><span class="s3"><span class="Apple-tab-span"> </span></span><span class="s1">Server</span><span class="s3">.internal.scope; </span>// you could also use 's' if the internal is the default</p>
79 <p class="p10"><br></p>
80 <p class="p3">You can do the same thing by clicking on the internal server window and pressing the 's' key.</p>
81 <p class="p10"><br></p>
82 <p class="p8"><b>Local vs. Internal</b></p>
83 <p class="p4"><br></p>
84 <p class="p3">If you're wondering what's the difference between the local and the internal servers, it's relatively straightforward: The internal server runs as a process within the client app; basically a program within a program. The main advantage of this is that it allows the two applications to share memory, which allows for things like realtime scoping of audio. The disadvantage is that the two are then interdependent, so if the client crashes, so does the server.</p>
85 <p class="p4"><br></p>
86 <p class="p3">For more information see:<b><span class="Apple-converted-space"> </span></b></p>
87 <p class="p4"><br></p>
88 <p class="p11"><a href="../../Core/Kernel/Function.html">Function</a><span class="s3"><b> </b><a href="../../ServerArchitecture/Server.html"><span class="s2">Server</span></a><b> </b><a href="../../GUI/Main-GUI/Stethoscope.html"><span class="s2">Stethoscope</span></a></span></p>
89 <p class="p4"><br></p>
90 <p class="p8"><b>Suggested Exercise:</b></p>
91 <p class="p10"><br></p>
92 <p class="p3">Experiment with scoping and plotting some of the Function examples from earlier sections, or some Functions of your own creation. Try experimenting with different duration or zoom values.</p>
93 <p class="p4"><br></p>
94 <p class="p3">____________________</p>
95 <p class="p4"><br></p>
96 <p class="p3">This document is part of the tutorial <b>Getting Started With SuperCollider</b>.</p>
97 <p class="p4"><br></p>
98 <p class="p3">Click here to go on to the next section: <a href="Getting Help.html"><span class="s4">Getting Help</span></a></p>
99 <p class="p4"><br></p>
100 <p class="p3">Click here to return to the table of Contents: <a href="Getting Started With SC.html"><span class="s4">Getting Started With SC</span></a></p>
101 </body>
102 </html>